home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
examples
/
chap04
/
Car.wrl
< prev
next >
Wrap
Text File
|
1996-10-14
|
2KB
|
67 lines
#VRML V2.0 utf8
#
# a car running on the street.
# you get on/off the car by clicking it.
#
# inline a scenary to make you realize your viewpoint is moving.
Transform{
translation -20 0 0
rotation 0 1 0 1.57
children[
Inline{url "world.wrl"}
]
}
# your default viewpoint.
DEF DEFAULT_VIEWPOINT Viewpoint{
position 5 2 20
orientation 0 1 0 1.0
}
DEF CAR Transform{
children[
# car itself.
Inline{url "CarBody.wrl"},
# touch sensor to get on/off the car.
DEF CAR_TOUCH TouchSensor{},
# viewpoint located at the driver's seat.
DEF CAR_VIEWPOINT Viewpoint{
position 0 2 0
orientation 0 1 0 3.14
}
]
}
DEF CAR_TIME TimeSensor{
loop TRUE
cycleInterval 6
}
DEF CAR_POSINT PositionInterpolator{
key [0, 0.5, 1]
keyValue [0 0 0, 0 0 20, 0 0 0]
}
DEF CAR_SCRIPT Script{
url "Car.class"
# get on/off the car.
eventIn SFTime touched
eventOut SFBool bindCarViewpoint
eventOut SFBool bindDefaultViewpoint
}
# make the car moving.
ROUTE CAR_TIME.fraction_changed TO CAR_POSINT.set_fraction
ROUTE CAR_POSINT.value_changed TO CAR.set_translation
# get on/off the car.
ROUTE CAR_TOUCH.touchTime TO CAR_SCRIPT.touched
ROUTE CAR_SCRIPT.bindCarViewpoint TO CAR_VIEWPOINT.set_bind
ROUTE CAR_SCRIPT.bindDefaultViewpoint TO DEFAULT_VIEWPOINT.set_bind